--[[=========================================================
	FIREMODE
=========================================================]]--

--[[-----------------------------------------------------]]--
--	Constructor
--[[-----------------------------------------------------]]--
ObjFiremode						= class( function(
								self,
								id,
								name,
								display,
								col,
								automatic,
								ammoType,
								clipSize,
								defaultClip,
								burstCount,
								reloadCount,
								buckShotCount,
								dmgInfo,
								meleeDmg,
								spread,
								precision,
								recoilUp,
								recoilDown,
								recoilLeft,
								recoilRight,
								muzzleEffect,
								swayScaleNormal,
								swayScaleSights,
								bobScaleNormal,
								bobScaleSights,
								idleDelay,
								deployDelay,
								shootDelay,
								reloadDelay,
								burstDelay,
								stopReloadDelay,
								switchModeDelay,
								sightsInDelay,
								sightsOutDelay,
								scopeInDelay,
								scopeOutDelay,
								holsterInDelay,
								holsterOutDelay,
								runInDelay,
								runOutDelay,
								wallInDelay,
								wallOutDelay,
								meleeDelay,
								idleSound,
								deploySound,
								shootSound,
								emptySound,
								reloadSound,
								stopReloadSound,
								switchModeSound,
								sightsInSound,
								sightsOutSound,
								scopeInSound,
								scopeOutSound,
								holsterInSound,
								holsterOutSound,
								runInSound,
								runOutSound,
								wallInSound,
								wallOutSound,
								meleeSound,
								idleActivity,
								deployActivity,
								shootActivity,
								reloadActivity,
								stopReloadActivity,
								switchModeActivity,
								sightsInActivity,
								sightsOutActivity,
								scopeInActivity,
								scopeOutActivity,
								holsterInActivity,
								holsterOutActivity,
								runActivity,
								wallActivity,
								meleeActivity,
								modePicture,
								ammoPicture,
								scopePicture,
								sightsTransform,
								holsterTransform,
								runTransform,
								runHolsteredTransform,
								wallTransform,
								wallHolsteredTransform,
								meleeTransform,
								scopeTransform )
	
	--	Members
	self.TableName				= "Firemode"
	self.ID						= ValOrDef( id, "integer", 0 )
	self.Name					= ValOrDef( name, "string", "" )
	self.Display				= ValOrDef( display, "string", "" )
	self.Color					= ValOrDef( col, "Color", color.DEFAULT )
	self.Automatic				= ValOrDef( automatic, "boolean", true )
	self.AmmoType				= ValOrDef( ammoType, "string", "smg1" )
	self.ClipSize				= ValOrDef( clipSize, "integer", 0 )
	self.DefaultClip			= ValOrDef( defaultClip, "integer", 0 )
	self.BurstCount				= ValOrDef( burstCount, "integer", 1 )
	self.ReloadCount			= ValOrDef( reloadCount, "integer", 1 )
	self.BuckShotCount			= ValOrDef( buckShotCount, "integer", 1 )
	self.DamageInfo				= ValOrDef( dmgInfo, ObjDamageInfo, ObjDamageInfo() )
	self.MeleeDamage			= ValOrDef( meleeDmg, ObjDamageInfo, ObjDamageInfo() )
	self.Spread					= ValOrDef( spread, "number", 0 )
	self.Precision				= ValOrDef( precision, "number", 1 )
	self.RecoilUp				= ValOrDef( recoilUp, "number", 0 )
	self.RecoilDown				= ValOrDef( recoilDown, "number", 0 )
	self.RecoilLeft				= ValOrDef( recoilLeft, "number", 0 )
	self.RecoilRight			= ValOrDef( recoilRight, "number", 0 )
	self.MuzzleEffect			= ValOrDef( muzzleEffect, "string", "" )
	self.SwayScale				= ValOrDef( swayScaleNormal, "number", 0 )
	self.SwayScaleSights		= ValOrDef( swayScaleSights, "number", 0 )
	self.BobScale				= ValOrDef( bobScaleNormal, "number", 0 )
	self.BobScaleSights			= ValOrDef( bobScaleSights, "number", 1 )
	self.IdleDelay				= ValOrDef( idleDelay, "number", 1 )
	self.DeployDelay			= ValOrDef( deployDelay, "number", 1 )
	self.ShootDelay				= ValOrDef( shootDelay, "number", 0.5 )
	self.ReloadDelay			= ValOrDef( reloadDelay, "number", 0.5 )
	self.BurstDelay				= ValOrDef( burstDelay, "number", 0.5 )
	self.StopReloadDelay		= ValOrDef( stopReloadDelay, "number", 0.5 )
	self.SwitchModeDelay		= ValOrDef( switchModeDelay, "number", 0.5 )
	self.SightsInDelay			= ValOrDef( sightsInDelay, "number", 0.5 )
	self.SightsOutDelay			= ValOrDef( sightsOutDelay, "number", 0.5 )
	self.ScopeInDelay			= ValOrDef( scopeInDelay, "number", 0.5 )
	self.ScopeOutDelay			= ValOrDef( scopeOutDelay, "number", 0.5 )
	self.HolsterInDelay			= ValOrDef( holsterInDelay, "number", 0.5 )
	self.HolsterOutDelay		= ValOrDef( holsterOutDelay, "number", 0.5 )
	self.RunInDelay				= ValOrDef( runInDelay, "number", 0.5 )
	self.RunOutDelay			= ValOrDef( runOutDelay, "number", 0.5 )
	self.WallInDelay			= ValOrDef( wallInDelay, "number", 0.5 )
	self.WallOutDelay			= ValOrDef( wallOutDelay, "number", 0.5 )
	self.MeleeDelay				= ValOrDef( meleeDelay, "number", 0.5 )
	self.IdleSound				= ValOrDef( idleSound, ObjSoundInfo, ObjSoundInfo() )
	self.DeploySound			= ValOrDef( deploySound, ObjSoundInfo, ObjSoundInfo() )
	self.ShootSound				= ValOrDef( shootSound, ObjSoundInfo, ObjSoundInfo() )
	self.EmptySound				= ValOrDef( emptySound, ObjSoundInfo, ObjSoundInfo() )
	self.ReloadSound			= ValOrDef( reloadSound, ObjSoundInfo, ObjSoundInfo() )
	self.StopReloadSound		= ValOrDef( stopReloadSound, ObjSoundInfo, ObjSoundInfo() )
	self.SwitchModeSound		= ValOrDef( switchModeSound, ObjSoundInfo, ObjSoundInfo() )
	self.SightsInSound			= ValOrDef( sightsInSound, ObjSoundInfo, ObjSoundInfo() )
	self.SightsOutSound			= ValOrDef( sightsOutSound, ObjSoundInfo, ObjSoundInfo() )
	self.ScopeInSound			= ValOrDef( scopeInSound, ObjSoundInfo, ObjSoundInfo() )
	self.ScopeOutSound			= ValOrDef( scopeOutSound, ObjSoundInfo, ObjSoundInfo() )
	self.HolsterInSound			= ValOrDef( holsterInSound, ObjSoundInfo, ObjSoundInfo() )
	self.HolsterOutSound		= ValOrDef( holsterOutSound, ObjSoundInfo, ObjSoundInfo() )
	self.RunInSound				= ValOrDef( runInSound, ObjSoundInfo, ObjSoundInfo() )
	self.RunOutSound			= ValOrDef( runOutSound, ObjSoundInfo, ObjSoundInfo() )
	self.WallInSound			= ValOrDef( wallInSound, ObjSoundInfo, ObjSoundInfo() )
	self.WallOutSound			= ValOrDef( wallOutSound, ObjSoundInfo, ObjSoundInfo() )
	self.MeleeSound				= ValOrDef( meleeSound, ObjSoundInfo, ObjSoundInfo() )
	self.IdleActivity			= ValOrDef( idleActivity, ObjActivityInfo, ObjActivityInfo() )
	self.DeployActivity			= ValOrDef( deployActivity, ObjActivityInfo, ObjActivityInfo() )
	self.ShootActivity			= ValOrDef( shootActivity, ObjActivityInfo, ObjActivityInfo() )
	self.ReloadActivity			= ValOrDef( reloadActivity, ObjActivityInfo, ObjActivityInfo() )
	self.StopReloadActivity		= ValOrDef( stopReloadActivity, ObjActivityInfo, ObjActivityInfo() )
	self.SwitchModeActivity		= ValOrDef( switchModeActivity, ObjActivityInfo, ObjActivityInfo() )
	self.SightsInActivity		= ValOrDef( sightsInActivity, ObjActivityInfo, ObjActivityInfo() )
	self.SightsOutActivity		= ValOrDef( sightsOutActivity, ObjActivityInfo, ObjActivityInfo() )
	self.ScopeInActivity		= ValOrDef( scopeInActivity, ObjActivityInfo, ObjActivityInfo() )
	self.ScopeOutActivity		= ValOrDef( scopeOutActivity, ObjActivityInfo, ObjActivityInfo() )
	self.HolsterInActivity		= ValOrDef( holsterInActivity, ObjActivityInfo, ObjActivityInfo() )
	self.HolsterOutActivity		= ValOrDef( holsterOutActivity, ObjActivityInfo, ObjActivityInfo() )
	self.RunActivity			= ValOrDef( runActivity, ObjActivityInfo, ObjActivityInfo() )
	self.WallActivity			= ValOrDef( wallActivity, ObjActivityInfo, ObjActivityInfo() )
	self.MeleeActivity			= ValOrDef( meleeActivity, ObjActivityInfo, ObjActivityInfo() )
	self.ModePicture			= ValOrDef( modePicture, "string", "" )
	self.AmmoPicture			= ValOrDef( ammoPicture, "string", "" )
	self.ScopePicture			= ValOrDef( scopePicture, "string", "" )
	self.SightsTransform		= ValOrDef( sightsTransform, ObjViewTransformInfo, ObjViewTransformInfo() )
	self.HolsterTransform		= ValOrDef( holsterTransform, ObjViewTransformInfo, ObjViewTransformInfo() )
	self.RunTransform			= ValOrDef( runTransform, ObjViewTransformInfo, ObjViewTransformInfo() )
	self.RunHolsteredTransform	= ValOrDef( runHolsteredTransform, ObjViewTransformInfo, ObjViewTransformInfo() )
	self.WallTransform			= ValOrDef( wallTransform, ObjViewTransformInfo, ObjViewTransformInfo() )
	self.WallHolsteredTransform	= ValOrDef( wallHolsteredTransform, ObjViewTransformInfo, ObjViewTransformInfo() )
	self.MeleeTransform			= ValOrDef( meleeTransform, ObjViewTransformInfo, ObjViewTransformInfo() )
	self.ScopeTransform			= ValOrDef( scopeTransform, ObjViewTransformInfo, ObjViewTransformInfo() )
	
--	SQL management - SERVER only
if SERVER then
	
	--	SQL Insert ( table, ids, contents )
	self.Insert					= function( self )
	
		--	Variables
		local result			= nil
		
		--	Insert links
		self.DamageInfo:Insert()
		self.MeleeDamage:Insert()
		self.IdleSound:Insert()
		self.DeploySound:Insert()
		self.ShootSound:Insert()
		self.EmptySound:Insert()
		self.ReloadSound:Insert()
		self.StopReloadSound:Insert()
		self.SwitchModeSound:Insert()
		self.SightsInSound:Insert()
		self.SightsOutSound:Insert()
		self.ScopeInSound:Insert()
		self.ScopeOutSound:Insert()
		self.HolsterInSound:Insert()
		self.HolsterOutSound:Insert()
		self.RunInSound:Insert()
		self.RunOutSound:Insert()
		self.WallInSound:Insert()
		self.WallOutSound:Insert()
		self.MeleeSound:Insert()
		self.IdleActivity:Insert()
		self.DeployActivity:Insert()
		self.ShootActivity:Insert()
		self.ReloadActivity:Insert()
		self.StopReloadActivity:Insert()
		self.SwitchModeActivity:Insert()
		self.SightsInActivity:Insert()
		self.SightsOutActivity:Insert()
		self.ScopeInActivity:Insert()
		self.ScopeOutActivity:Insert()
		self.HolsterInActivity:Insert()
		self.HolsterOutActivity:Insert()
		self.RunActivity:Insert()
		self.WallActivity:Insert()
		self.MeleeActivity:Insert()
		self.SightsTransform:Insert()
		self.HolsterTransform:Insert()
		self.RunTransform:Insert()
		self.RunHolsteredTransform:Insert()
		self.WallTransform:Insert()
		self.WallHolsteredTransform:Insert()
		self.MeleeTransform:Insert()
		self.ScopeTransform:Insert()
	
		--	Generate a new ID
		if self.ID == 0 then
			self.ID				=
				sql.GetNewID(
					self.TableName,
					FieldInfo( "ID", self.ID, "number" )
				)
		end
		
		--	Insert in DB if we got an ID
		if self.ID != 0 then
			result = sql.Insert(
				self.TableName,
				{ 1 },
				FieldInfo( "ID", self.ID, "number" ),
				FieldInfo( "Name", self.Name, "string" ),
				FieldInfo( "Display", self.Display, "string" ),
				FieldInfo( "Color", color.ToHexString( self.Color ), "string" ),
				FieldInfo( "Automatic", self.Automatic, "boolean" ),
				FieldInfo( "AmmoType", self.AmmoType, "string" ),
				FieldInfo( "ClipSize", self.ClipSize, "number" ),
				FieldInfo( "DefaultClip", self.DefaultClip, "number" ),
				FieldInfo( "BurstCount", self.BurstCount, "number" ),
				FieldInfo( "ReloadCount", self.ReloadCount, "number" ),
				FieldInfo( "BuckShotCount", self.BuckShotCount, "number" ),
				FieldInfo( "DamageInfo", self.DamageInfo.ID, "number" ),
				FieldInfo( "MeleeDamage", self.MeleeDamage.ID, "number" ),
				FieldInfo( "Spread", self.Spread, "number" ),
				FieldInfo( "Precision", self.Precision, "number" ),
				FieldInfo( "RecoilUp", self.RecoilUp, "number" ),
				FieldInfo( "RecoilDown", self.RecoilDown, "number" ),
				FieldInfo( "RecoilLeft", self.RecoilLeft, "number" ),
				FieldInfo( "RecoilRight", self.RecoilRight, "number" ),
				FieldInfo( "MuzzleEffect", self.MuzzleEffect, "string" ),
				FieldInfo( "SwayScaleNormal", self.SwayScale, "number" ),
				FieldInfo( "SwayScaleIronSights", self.SwayScaleSights, "number" ),
				FieldInfo( "BobScaleNormal", self.BobScale, "number" ),
				FieldInfo( "BobScaleIronSights", self.BobScaleSights, "number" ),
				FieldInfo( "IdleDelay", self.IdleDelay, "number" ),
				FieldInfo( "DeployDelay", self.DeployDelay, "number" ),
				FieldInfo( "ShootDelay", self.ShootDelay, "number" ),
				FieldInfo( "ReloadDelay", self.ReloadDelay, "number" ),
				FieldInfo( "BurstDelay", self.BurstDelay, "number" ),
				FieldInfo( "StopReloadDelay", self.StopReloadDelay, "number" ),
				FieldInfo( "SwitchModeDelay", self.SwitchModeDelay, "number" ),
				FieldInfo( "SightsInDelay", self.SightsInDelay, "number" ),
				FieldInfo( "SightsOutDelay", self.SightsOutDelay, "number" ),
				FieldInfo( "ScopeInDelay", self.ScopeInDelay, "number" ),
				FieldInfo( "ScopeOutDelay", self.ScopeOutDelay, "number" ),
				FieldInfo( "HolsterInDelay", self.HolsterInDelay, "number" ),
				FieldInfo( "HolsterOutDelay", self.HolsterOutDelay, "number" ),
				FieldInfo( "RunInDelay", self.RunInDelay, "number" ),
				FieldInfo( "RunOutDelay", self.RunOutDelay, "number" ),
				FieldInfo( "WallInDelay", self.WallInDelay, "number" ),
				FieldInfo( "WallOutDelay", self.WallOutDelay, "number" ),
				FieldInfo( "MeleeDelay", self.MeleeDelay, "number" ),
				FieldInfo( "IdleSound", self.IdleSound.ID, "number" ),
				FieldInfo( "DeploySound", self.DeploySound.ID, "number" ),
				FieldInfo( "ShootSound", self.ShootSound.ID, "number" ),
				FieldInfo( "EmptySound", self.EmptySound.ID, "number" ),
				FieldInfo( "ReloadSound", self.ReloadSound.ID, "number" ),
				FieldInfo( "StopReloadSound", self.StopReloadSound.ID, "number" ),
				FieldInfo( "SwitchModeSound", self.SwitchModeSound.ID, "number" ),
				FieldInfo( "SightsInSound", self.SightsInSound.ID, "number" ),
				FieldInfo( "SightsOutSound", self.SightsOutSound.ID, "number" ),
				FieldInfo( "ScopeInSound", self.ScopeInSound.ID, "number" ),
				FieldInfo( "ScopeOutSound", self.ScopeOutSound.ID, "number" ),
				FieldInfo( "HolsterInSound", self.HolsterInSound.ID, "number" ),
				FieldInfo( "HolsterOutSound", self.HolsterOutSound.ID, "number" ),
				FieldInfo( "RunInSound", self.RunInSound.ID, "number" ),
				FieldInfo( "RunOutSound", self.RunOutSound.ID, "number" ),
				FieldInfo( "WallInSound", self.WallInSound.ID, "number" ),
				FieldInfo( "WallOutSound", self.WallOutSound.ID, "number" ),
				FieldInfo( "MeleeSound", self.MeleeSound.ID, "number" ),
				FieldInfo( "IdleActivity", self.IdleActivity.ID, "number" ),
				FieldInfo( "DeployActivity", self.DeployActivity.ID, "number" ),
				FieldInfo( "ShootActivity", self.ShootActivity.ID, "number" ),
				FieldInfo( "ReloadActivity", self.ReloadActivity.ID, "number" ),
				FieldInfo( "StopReloadActivity", self.StopReloadActivity.ID, "number" ),
				FieldInfo( "SwitchModeActivity", self.SwitchModeActivity.ID, "number" ),
				FieldInfo( "SightsInActivity", self.SightsInActivity.ID, "number" ),
				FieldInfo( "SightsOutActivity", self.SightsOutActivity.ID, "number" ),
				FieldInfo( "ScopeInActivity", self.ScopeInActivity.ID, "number" ),
				FieldInfo( "ScopeOutActivity", self.ScopeOutActivity.ID, "number" ),
				FieldInfo( "HolsterInActivity", self.HolsterInActivity.ID, "number" ),
				FieldInfo( "HolsterOutActivity", self.HolsterOutActivity.ID, "number" ),
				FieldInfo( "RunActivity", self.RunActivity.ID, "number" ),
				FieldInfo( "WallActivity", self.WallActivity.ID, "number" ),
				FieldInfo( "MeleeActivity", self.MeleeActivity.ID, "number" ),
				FieldInfo( "ModePicture", self.ModePicture, "string" ),
				FieldInfo( "AmmoPicture", self.AmmoPicture, "string" ),
				FieldInfo( "ScopePicture", self.ScopePicture, "string" ),
				FieldInfo( "SightsTransform", self.SightsTransform.ID, "number" ),
				FieldInfo( "HolsterTransform", self.HolsterTransform.ID, "number" ),
				FieldInfo( "RunTransform", self.RunTransform.ID, "number" ),
				FieldInfo( "RunHolsteredTransform", self.RunHolsteredTransform.ID, "number" ),
				FieldInfo( "WallTransform", self.WallTransform.ID, "number" ),
				FieldInfo( "WallHolsteredTransform", self.WallHolsteredTransform.ID, "number" ),
				FieldInfo( "MeleeTransform", self.MeleeTransform.ID, "number" ),
				FieldInfo( "ScopeTransform", self.ScopeTransform.ID, "number" )
			)
		end
	end
	
	--	SQL Update ( table, ids, contents )
	self.Update					= function( self )
	
		--	Variables
		local result			= nil
		
		--	Update links
		self.DamageInfo:Update()
		self.MeleeDamage:Update()
		self.IdleSound:Update()
		self.DeploySound:Update()
		self.ShootSound:Update()
		self.EmptySound:Update()
		self.ReloadSound:Update()
		self.StopReloadSound:Update()
		self.SwitchModeSound:Update()
		self.SightsInSound:Update()
		self.SightsOutSound:Update()
		self.ScopeInSound:Update()
		self.ScopeOutSound:Update()
		self.HolsterInSound:Update()
		self.HolsterOutSound:Update()
		self.RunInSound:Update()
		self.RunOutSound:Update()
		self.WallInSound:Update()
		self.WallOutSound:Update()
		self.MeleeSound:Update()
		self.IdleActivity:Update()
		self.DeployActivity:Update()
		self.ShootActivity:Update()
		self.ReloadActivity:Update()
		self.StopReloadActivity:Update()
		self.SwitchModeActivity:Update()
		self.SightsInActivity:Update()
		self.SightsOutActivity:Update()
		self.ScopeInActivity:Update()
		self.ScopeOutActivity:Update()
		self.HolsterInActivity:Update()
		self.HolsterOutActivity:Update()
		self.RunActivity:Update()
		self.WallActivity:Update()
		self.MeleeActivity:Update()
		self.SightsTransform:Update()
		self.HolsterTransform:Update()
		self.RunTransform:Update()
		self.RunHolsteredTransform:Update()
		self.WallTransform:Update()
		self.WallHolsteredTransform:Update()
		self.MeleeTransform:Update()
		self.ScopeTransform:Update()
	
		--	Update in DB
		result = sql.Update(
			self.TableName,
			{ 1 },
			FieldInfo( "ID", self.ID, "number" ),
			FieldInfo( "Name", self.Name, "string" ),
			FieldInfo( "Display", self.Display, "string" ),
			FieldInfo( "Color", color.ToHexString( self.Color ), "string" ),
			FieldInfo( "Automatic", self.Automatic, "boolean" ),
			FieldInfo( "AmmoType", self.AmmoType, "string" ),
			FieldInfo( "ClipSize", self.ClipSize, "number" ),
			FieldInfo( "DefaultClip", self.DefaultClip, "number" ),
			FieldInfo( "BurstCount", self.BurstCount, "number" ),
			FieldInfo( "ReloadCount", self.ReloadCount, "number" ),
			FieldInfo( "BuckShotCount", self.BuckShotCount, "number" ),
			FieldInfo( "DamageInfo", self.DamageInfo.ID, "number" ),
			FieldInfo( "MeleeDamage", self.MeleeDamage.ID, "number" ),
			FieldInfo( "Spread", self.Spread, "number" ),
			FieldInfo( "Precision", self.Precision, "number" ),
			FieldInfo( "RecoilUp", self.RecoilUp, "number" ),
			FieldInfo( "RecoilDown", self.RecoilDown, "number" ),
			FieldInfo( "RecoilLeft", self.RecoilLeft, "number" ),
			FieldInfo( "RecoilRight", self.RecoilRight, "number" ),
			FieldInfo( "MuzzleEffect", self.MuzzleEffect, "string" ),
			FieldInfo( "SwayScaleNormal", self.SwayScale, "number" ),
			FieldInfo( "SwayScaleIronSights", self.SwayScaleSights, "number" ),
			FieldInfo( "BobScaleNormal", self.BobScale, "number" ),
			FieldInfo( "BobScaleIronSights", self.BobScaleSights, "number" ),
			FieldInfo( "IdleDelay", self.IdleDelay, "number" ),
			FieldInfo( "DeployDelay", self.DeployDelay, "number" ),
			FieldInfo( "ShootDelay", self.ShootDelay, "number" ),
			FieldInfo( "ReloadDelay", self.ReloadDelay, "number" ),
			FieldInfo( "BurstDelay", self.BurstDelay, "number" ),
			FieldInfo( "StopReloadDelay", self.StopReloadDelay, "number" ),
			FieldInfo( "SwitchModeDelay", self.SwitchModeDelay, "number" ),
			FieldInfo( "SightsInDelay", self.SightsInDelay, "number" ),
			FieldInfo( "SightsOutDelay", self.SightsOutDelay, "number" ),
			FieldInfo( "ScopeInDelay", self.ScopeInDelay, "number" ),
			FieldInfo( "ScopeOutDelay", self.ScopeOutDelay, "number" ),
			FieldInfo( "HolsterInDelay", self.HolsterInDelay, "number" ),
			FieldInfo( "HolsterOutDelay", self.HolsterOutDelay, "number" ),
			FieldInfo( "RunInDelay", self.RunInDelay, "number" ),
			FieldInfo( "RunOutDelay", self.RunOutDelay, "number" ),
			FieldInfo( "WallInDelay", self.WallInDelay, "number" ),
			FieldInfo( "WallOutDelay", self.WallOutDelay, "number" ),
			FieldInfo( "MeleeDelay", self.MeleeDelay, "number" ),
			FieldInfo( "IdleSound", self.IdleSound, "number" ),
			FieldInfo( "DeploySound", self.DeploySound.ID, "number" ),
			FieldInfo( "ShootSound", self.ShootSound.ID, "number" ),
			FieldInfo( "EmptySound", self.EmptySound.ID, "number" ),
			FieldInfo( "ReloadSound", self.ReloadSound.ID, "number" ),
			FieldInfo( "StopReloadSound", self.StopReloadSound.ID, "number" ),
			FieldInfo( "SwitchModeSound", self.SwitchModeSound.ID, "number" ),
			FieldInfo( "SightsInSound", self.SightsInSound.ID, "number" ),
			FieldInfo( "SightsOutSound", self.SightsOutSound.ID, "number" ),
			FieldInfo( "ScopeInSound", self.ScopeInSound.ID, "number" ),
			FieldInfo( "ScopeOutSound", self.ScopeOutSound.ID, "number" ),
			FieldInfo( "HolsterInSound", self.HolsterInSound.ID, "number" ),
			FieldInfo( "HolsterOutSound", self.HolsterOutSound.ID, "number" ),
			FieldInfo( "RunInSound", self.RunInSound.ID, "number" ),
			FieldInfo( "RunOutSound", self.RunOutSound.ID, "number" ),
			FieldInfo( "WallInSound", self.WallInSound.ID, "number" ),
			FieldInfo( "WallOutSound", self.WallOutSound.ID, "number" ),
			FieldInfo( "MeleeSound", self.MeleeSound.ID, "number" ),
			FieldInfo( "IdleActivity", self.IdleActivity.ID, "number" ),
			FieldInfo( "DeployActivity", self.DeployActivity.ID, "number" ),
			FieldInfo( "ShootActivity", self.ShootActivity.ID, "number" ),
			FieldInfo( "ReloadActivity", self.ReloadActivity.ID, "number" ),
			FieldInfo( "StopReloadActivity", self.StopReloadActivity.ID, "number" ),
			FieldInfo( "SwitchModeActivity", self.SwitchModeActivity.ID, "number" ),
			FieldInfo( "SightsInActivity", self.SightsInActivity.ID, "number" ),
			FieldInfo( "SightsOutActivity", self.SightsOutActivity.ID, "number" ),
			FieldInfo( "ScopeInActivity", self.ScopeInActivity.ID, "number" ),
			FieldInfo( "ScopeOutActivity", self.ScopeOutActivity.ID, "number" ),
			FieldInfo( "HolsterInActivity", self.HolsterInActivity.ID, "number" ),
			FieldInfo( "HolsterOutActivity", self.HolsterOutActivity.ID, "number" ),
			FieldInfo( "RunActivity", self.RunActivity.ID, "number" ),
			FieldInfo( "WallActivity", self.WallActivity.ID, "number" ),
			FieldInfo( "MeleeActivity", self.MeleeActivity.ID, "number" ),
			FieldInfo( "ModePicture", self.ModePicture, "string" ),
			FieldInfo( "AmmoPicture", self.AmmoPicture, "string" ),
			FieldInfo( "ScopePicture", self.ScopePicture, "string" ),
			FieldInfo( "SightsTransform", self.SightsTransform.ID, "number" ),
			FieldInfo( "HolsterTransform", self.HolsterTransform.ID, "number" ),
			FieldInfo( "RunTransform", self.RunTransform.ID, "number" ),
			FieldInfo( "RunHolsteredTransform", self.RunHolsteredTransform.ID, "number" ),
			FieldInfo( "WallTransform", self.WallTransform.ID, "number" ),
			FieldInfo( "WallHolsteredTransform", self.WallHolsteredTransform.ID, "number" ),
			FieldInfo( "MeleeTransform", self.MeleeTransform.ID, "number" ),
			FieldInfo( "ScopeTransform", self.ScopeTransform.ID, "number" )
		)
	end
	
	--	SQL Delete ( table, ids, id contents )
	self.Delete					= function( self )
	
		--	Variables
		local result			= nil
	
		--	Delete from DB
		result = sql.Delete(
			self.TableName,
			{ 1 },
			FieldInfo( "ID", self.ID, "number" )
		)
		
		--	Reset ID if it was deleted
		if result then
			self.ID				= 0
		end
	end
	
	--	SQL Reload ( table, ids, id contents )
	self.Reload					= function( self, id )
	
		--	Redefinie id if needed
		if IsInt( id ) then
			self.ID				= id
		end
	
		--	Retrieve from DB
		self:FillProperties(
			sql.GetRow(
				self.TableName,
				{ 1 },
				FieldInfo( "ID", self.ID, "number" ),
				FieldInfo( "Name", self.Name, "string" ),
				FieldInfo( "Display", self.Display, "string" ),
				FieldInfo( "Color", color.ToHexString( self.Color ), "string" ),
				FieldInfo( "Automatic", self.Automatic, "boolean" ),
				FieldInfo( "AmmoType", self.AmmoType, "string" ),
				FieldInfo( "ClipSize", self.ClipSize, "number" ),
				FieldInfo( "DefaultClip", self.DefaultClip, "number" ),
				FieldInfo( "BurstCount", self.BurstCount, "number" ),
				FieldInfo( "ReloadCount", self.ReloadCount, "number" ),
				FieldInfo( "BuckShotCount", self.BuckShotCount, "number" ),
				FieldInfo( "DamageInfo", self.DamageInfo.ID, "number" ),
				FieldInfo( "MeleeDamage", self.MeleeDamage.ID, "number" ),
				FieldInfo( "Spread", self.Spread, "number" ),
				FieldInfo( "Precision", self.Precision, "number" ),
				FieldInfo( "RecoilUp", self.RecoilUp, "number" ),
				FieldInfo( "RecoilDown", self.RecoilDown, "number" ),
				FieldInfo( "RecoilLeft", self.RecoilLeft, "number" ),
				FieldInfo( "RecoilRight", self.RecoilRight, "number" ),
				FieldInfo( "MuzzleEffect", self.MuzzleEffect, "string" ),
				FieldInfo( "SwayScaleNormal", self.SwayScale, "number" ),
				FieldInfo( "SwayScaleIronSights", self.SwayScaleSights, "number" ),
				FieldInfo( "BobScaleNormal", self.BobScale, "number" ),
				FieldInfo( "BobScaleIronSights", self.BobScaleSights, "number" ),
				FieldInfo( "IdleDelay", self.IdleDelay, "number" ),
				FieldInfo( "DeployDelay", self.DeployDelay, "number" ),
				FieldInfo( "ShootDelay", self.ShootDelay, "number" ),
				FieldInfo( "ReloadDelay", self.ReloadDelay, "number" ),
				FieldInfo( "BurstDelay", self.BurstDelay, "number" ),
				FieldInfo( "StopReloadDelay", self.StopReloadDelay, "number" ),
				FieldInfo( "SwitchModeDelay", self.SwitchModeDelay, "number" ),
				FieldInfo( "SightsInDelay", self.SightsInDelay, "number" ),
				FieldInfo( "SightsOutDelay", self.SightsOutDelay, "number" ),
				FieldInfo( "ScopeInDelay", self.ScopeInDelay, "number" ),
				FieldInfo( "ScopeOutDelay", self.ScopeOutDelay, "number" ),
				FieldInfo( "HolsterInDelay", self.HolsterInDelay, "number" ),
				FieldInfo( "HolsterOutDelay", self.HolsterOutDelay, "number" ),
				FieldInfo( "RunInDelay", self.RunInDelay, "number" ),
				FieldInfo( "RunOutDelay", self.RunOutDelay, "number" ),
				FieldInfo( "WallInDelay", self.WallInDelay, "number" ),
				FieldInfo( "WallOutDelay", self.WallOutDelay, "number" ),
				FieldInfo( "MeleeDelay", self.MeleeDelay, "number" ),
				FieldInfo( "IdleSound", self.IdleSound, "number" ),
				FieldInfo( "DeploySound", self.DeploySound.ID, "number" ),
				FieldInfo( "ShootSound", self.ShootSound.ID, "number" ),
				FieldInfo( "EmptySound", self.EmptySound.ID, "number" ),
				FieldInfo( "ReloadSound", self.ReloadSound.ID, "number" ),
				FieldInfo( "StopReloadSound", self.StopReloadSound.ID, "number" ),
				FieldInfo( "SwitchModeSound", self.SwitchModeSound.ID, "number" ),
				FieldInfo( "SightsInSound", self.SightsInSound.ID, "number" ),
				FieldInfo( "SightsOutSound", self.SightsOutSound.ID, "number" ),
				FieldInfo( "ScopeInSound", self.ScopeInSound.ID, "number" ),
				FieldInfo( "ScopeOutSound", self.ScopeOutSound.ID, "number" ),
				FieldInfo( "HolsterInSound", self.HolsterInSound.ID, "number" ),
				FieldInfo( "HolsterOutSound", self.HolsterOutSound.ID, "number" ),
				FieldInfo( "RunInSound", self.RunInSound.ID, "number" ),
				FieldInfo( "RunOutSound", self.RunOutSound.ID, "number" ),
				FieldInfo( "WallInSound", self.WallInSound.ID, "number" ),
				FieldInfo( "WallOutSound", self.WallOutSound.ID, "number" ),
				FieldInfo( "MeleeSound", self.MeleeSound.ID, "number" ),
				FieldInfo( "IdleActivity", self.IdleActivity.ID, "number" ),
				FieldInfo( "DeployActivity", self.DeployActivity.ID, "number" ),
				FieldInfo( "ShootActivity", self.ShootActivity.ID, "number" ),
				FieldInfo( "ReloadActivity", self.ReloadActivity.ID, "number" ),
				FieldInfo( "StopReloadActivity", self.StopReloadActivity.ID, "number" ),
				FieldInfo( "SwitchModeActivity", self.SwitchModeActivity.ID, "number" ),
				FieldInfo( "SightsInActivity", self.SightsInActivity.ID, "number" ),
				FieldInfo( "SightsOutActivity", self.SightsOutActivity.ID, "number" ),
				FieldInfo( "ScopeInActivity", self.ScopeInActivity.ID, "number" ),
				FieldInfo( "ScopeOutActivity", self.ScopeOutActivity.ID, "number" ),
				FieldInfo( "HolsterInActivity", self.HolsterInActivity.ID, "number" ),
				FieldInfo( "HolsterOutActivity", self.HolsterOutActivity.ID, "number" ),
				FieldInfo( "RunActivity", self.RunActivity.ID, "number" ),
				FieldInfo( "WallActivity", self.WallActivity.ID, "number" ),
				FieldInfo( "MeleeActivity", self.MeleeActivity.ID, "number" ),
				FieldInfo( "ModePicture", self.ModePicture, "string" ),
				FieldInfo( "AmmoPicture", self.AmmoPicture, "string" ),
				FieldInfo( "ScopePicture", self.ScopePicture, "string" ),
				FieldInfo( "SightsTransform", self.SightsTransform.ID, "number" ),
				FieldInfo( "HolsterTransform", self.HolsterTransform.ID, "number" ),
				FieldInfo( "RunTransform", self.RunTransform.ID, "number" ),
				FieldInfo( "RunHolsteredTransform", self.RunHolsteredTransform.ID, "number" ),
				FieldInfo( "WallTransform", self.WallTransform.ID, "number" ),
				FieldInfo( "WallHolsteredTransform", self.WallHolsteredTransform.ID, "number" ),
				FieldInfo( "MeleeTransform", self.MeleeTransform.ID, "number" ),
				FieldInfo( "ScopeTransform", self.ScopeTransform.ID, "number" )
			)
		)
	end
	
	--	Assign fields from row
	self.FillProperties			= function( self, row )
		self.Name				= tostring( row["Name"] )
		self.Display			= tostring( row["Display"] )
		self.Color				= color.FromHexString( tostring( row["Color"] ) )
		self.Automatic			= tobool( row["Automatic"] )
		self.AmmoType			= tostring( row["AmmoType"] )
		self.ClipSize			= tonumber( row["ClipSize"] )
		self.DefaultClip		= tonumber( row["DefaultClip"] )
		self.BurstCount			= tonumber( row["BurstCount"] )
		self.ReloadCount		= tonumber( row["ReloadCount"] )
		self.BuckShotCount		= tonumber( row["BuckShotCount"] )
		self.DamageInfo:Reload( tonumber( row["DamageInfo"] ) )
		self.MeleeDamage:Reload( tonumber( row["MeleeDamage"] ) )
		self.Spread				= tonumber( row["Spread"] )
		self.Precision			= tonumber( row["Precision"] )
		self.RecoilUp			= tonumber( row["RecoilUp"] )
		self.RecoilDown			= tonumber( row["RecoilDown"] )
		self.RecoilLeft			= tonumber( row["RecoilLeft"] )
		self.RecoilRight		= tonumber( row["RecoilRight"] )
		self.MuzzleEffect		= tostring( row["MuzzleEffect"] )
		self.SwayScale			= tonumber( row["SwayScaleNormal"] )
		self.SwayScaleSights	= tonumber( row["SwayScaleIronSights"] )
		self.BobScale			= tonumber( row["BobScaleNormal"] )
		self.BobScaleSights		= tonumber( row["BobScaleIronSights"] )
		self.IdleDelay			= tonumber( row["IdleDelay"] )
		self.DeployDelay		= tonumber( row["DeployDelay"] )
		self.ShootDelay			= tonumber( row["ShootDelay"] )
		self.ReloadDelay		= tonumber( row["ReloadDelay"] )
		self.BurstDelay			= tonumber( row["BurstDelay"] )
		self.StopReloadDelay	= tonumber( row["StopReloadDelay"] )
		self.SwitchModeDelay	= tonumber( row["SwitchModeDelay"] )
		self.SightsInDelay		= tonumber( row["SightsInDelay"] )
		self.SightsOutDelay		= tonumber( row["SightsOutDelay"] )
		self.ScopeInDelay		= tonumber( row["ScopeInDelay"] )
		self.ScopeOutDelay		= tonumber( row["ScopeOutDelay"] )
		self.HolsterInDelay		= tonumber( row["HolsterInDelay"] )
		self.HolsterOutDelay	= tonumber( row["HolsterOutDelay"] )
		self.RunInDelay			= tonumber( row["RunInDelay"] )
		self.RunOutDelay		= tonumber( row["RunOutDelay"] )
		self.WallInDelay		= tonumber( row["WallInDelay"] )
		self.WallOutDelay		= tonumber( row["WallOutDelay"] )
		self.MeleeDelay			= tonumber( row["MeleeDelay"] )
		self.IdleSound:Reload( tonumber( row["IdleSound"] ) )
		self.DeploySound:Reload( tonumber( row["DeploySound"] ) )
		self.ShootSound:Reload( tonumber( row["ShootSound"] ) )
		self.EmptySound:Reload( tonumber( row["EmptySound"] ) )
		self.ReloadSound:Reload( tonumber( row["ReloadSound"] ) )
		self.StopReloadSound:Reload( tonumber( row["StopReloadSound"] ) )
		self.SwitchModeSound:Reload( tonumber( row["SwitchModeSound"] ) )
		self.SightsInSound:Reload( tonumber( row["SightsInSound"] ) )
		self.SightsOutSound:Reload( tonumber( row["SightsOutSound"] ) )
		self.ScopeInSound:Reload( tonumber( row["ScopeInSound"] ) )
		self.ScopeOutSound:Reload( tonumber( row["ScopeOutSound"] ) )
		self.HolsterInSound:Reload( tonumber( row["HolsterInSound"] ) )
		self.HolsterOutSound:Reload( tonumber( row["HolsterOutSound"] ) )
		self.RunInSound:Reload( tonumber( row["RunInSound"] ) )
		self.RunOutSound:Reload( tonumber( row["RunOutSound"] ) )
		self.WallInSound:Reload( tonumber( row["WallInSound"] ) )
		self.WallOutSound:Reload( tonumber( row["WallOutSound"] ) )
		self.MeleeSound:Reload( tonumber( row["MeleeSound"] ) )
		self.IdleActivity:Reload( tonumber( row["IdleActivity"] ) )
		self.DeployActivity:Reload( tonumber( row["DeployActivity"] ) )
		self.ShootActivity:Reload( tonumber( row["ShootActivity"] ) )
		self.ReloadActivity	:Reload( tonumber( row["ReloadActivity"] ) )
		self.StopReloadActivity:Reload( tonumber( row["StopReloadActivity"] ) )
		self.SwitchModeActivity:Reload( tonumber( row["SwitchModeActivity"] ) )
		self.SightsInActivity:Reload( tonumber( row["SightsInActivity"] ) )
		self.SightsOutActivity:Reload( tonumber( row["SightsOutActivity"] ) )
		self.ScopeInActivity:Reload( tonumber( row["ScopeInActivity"] ) )
		self.ScopeOutActivity:Reload( tonumber( row["ScopeOutActivity"] ) )
		self.HolsterInActivity:Reload( tonumber( row["HolsterInActivity"] ) )
		self.HolsterOutActivity:Reload( tonumber( row["HolsterOutActivity"] ) )
		self.RunActivity:Reload( tonumber( row["RunActivity"] ) )
		self.WallActivity:Reload( tonumber( row["WallActivity"] ) )
		self.MeleeActivity:Reload( tonumber( row["MeleeActivity"] ) )
		self.ModePicture		= tostring( row["ModePicture"] )
		self.AmmoPicture		= tostring( row["AmmoPicture"] )
		self.ScopePicture		= tostring( row["ScopePicture"] )
		self.SightsTransform:Reload( tonumber( row["SightsTransform"] ) )
		self.HolsterTransform:Reload( tonumber( row["HolsterTransform"] ) )
		self.RunTransform:Reload(tonumber( row["RunTransform"] ) )
		self.RunHolsteredTransform:Reload( tonumber( row["RunHolsteredTransform"] ) )
		self.WallTransform:Reload( tonumber( row["WallTransform"] ) )
		self.WallHolsteredTransform:Reload( tonumber( row["WallHolsteredTransform"] ) )
		self.MeleeTransform:Reload( tonumber( row["MeleeTransform"] ) )
		self.ScopeTransform:Reload( tonumber( row["ScopeTransform"] ) )
	end
	
end	--	End of SQL management

--	Other server functions
if SERVER then

	--	Returns a table for transfers to clients
	self.GetClientTable				= function( self )
		return {
			["ID"]					= self.ID,
			["Name"]				= self.Name,
			["Display"]				= self.Display,
			["Color"]				= self.Color,
			["Automatic"]			= self.Automatic,
			["AmmoType"]			= self.AmmoType,
			["ClipSize"]			= self.ClipSize,
			["DefaultClip"]			= self.DefaultClip,
			["BurstCount"]			= self.BurstCount,
			["ReloadCount"]			= self.ReloadCount,
			["BuckShotCount"]		= self.BuckShotCount,
			["DamageInfo"]			= self.DamageInfo:GetClientTable(),
			["MeleeDamage"]			= self.MeleeDamage:GetClientTable(),
			["Spread"]				= self.Spread,
			["Precision"]			= self.Precision,
			["RecoilUp"]			= self.RecoilUp,
			["RecoilDown"]			= self.RecoilDown,
			["RecoilLeft"]			= self.RecoilLeft,
			["RecoilRight"]			= self.RecoilRight,
			["MuzzleEffect"]		= self.MuzzleEffect,
			["SwayScale"]			= self.SwayScale,
			["SwayScaleSights"]		= self.SwayScaleSights,
			["BobScale"]			= self.BobScale,
			["BobScaleSights"]		= self.BobScaleSights,
			["IdleDelay"]			= self.IdleDelay,
			["DeployDelay"]			= self.DeployDelay,
			["ShootDelay"]			= self.ShootDelay,
			["ReloadDelay"]			= self.ReloadDelay,
			["BurstDelay"]			= self.BurstDelay,
			["StopReloadDelay"]		= self.StopReloadDelay,
			["SwitchModeDelay"]		= self.SwitchModeDelay,
			["SightsInDelay"]		= self.SightsInDelay,
			["SightsOutDelay"]		= self.SightsOutDelay,
			["ScopeInDelay"]		= self.ScopeInDelay,
			["ScopeOutDelay"]		= self.ScopeOutDelay,
			["HolsterInDelay"]		= self.HolsterInDelay,
			["HolsterOutDelay"]		= self.HolsterOutDelay,
			["RunInDelay"]			= self.RunInDelay,
			["RunOutDelay"]			= self.RunOutDelay,
			["WallInDelay"]			= self.WallInDelay,
			["WallOutDelay"]		= self.WallOutDelay,
			["MeleeDelay"]			= self.MeleeDelay,
			["IdleSound"]			= self.IdleSound:GetClientTable(),
			["DeploySound"]			= self.DeploySound:GetClientTable(),
			["ShootSound"]			= self.ShootSound:GetClientTable(),
			["EmptySound"]			= self.EmptySound:GetClientTable(),
			["ReloadSound"]			= self.ReloadSound:GetClientTable(),
			["StopReloadSound"]		= self.StopReloadSound:GetClientTable(),
			["SwitchModeSound"]		= self.SwitchModeSound:GetClientTable(),
			["SightsInSound"]		= self.SightsInSound:GetClientTable(),
			["SightsOutSound"]		= self.SightsOutSound:GetClientTable(),
			["ScopeInSound"]		= self.ScopeInSound:GetClientTable(),
			["ScopeOutSound"]		= self.ScopeOutSound:GetClientTable(),
			["HolsterInSound"]		= self.HolsterInSound:GetClientTable(),
			["HolsterOutSound"]		= self.HolsterOutSound:GetClientTable(),
			["RunInSound"]			= self.RunInSound:GetClientTable(),
			["RunOutSound"]			= self.RunOutSound:GetClientTable(),
			["WallInSound"]			= self.WallInSound:GetClientTable(),
			["WallOutSound"]		= self.WallOutSound:GetClientTable(),
			["MeleeSound"]			= self.MeleeSound:GetClientTable(),
			["IdleActivity"]		= self.IdleActivity:GetClientTable(),
			["DeployActivity"]		= self.DeployActivity:GetClientTable(),
			["ShootActivity"]		= self.ShootActivity:GetClientTable(),
			["ReloadActivity"]		= self.ReloadActivity:GetClientTable(),
			["StopReloadActivity"]	= self.StopReloadActivity:GetClientTable(),
			["SwitchModeActivity"]	= self.SwitchModeActivity:GetClientTable(),
			["SightsInActivity"]	= self.SightsInActivity:GetClientTable(),
			["SightsOutActivity"]	= self.SightsOutActivity:GetClientTable(),
			["ScopeInActivity"]		= self.ScopeInActivity:GetClientTable(),
			["ScopeOutActivity"]	= self.ScopeOutActivity:GetClientTable(),
			["HolsterInActivity"]	= self.HolsterInActivity:GetClientTable(),
			["HolsterOutActivity"]	= self.HolsterOutActivity:GetClientTable(),
			["RunActivity"]			= self.RunActivity:GetClientTable(),
			["WallActivity"]		= self.WallActivity:GetClientTable(),
			["MeleeActivity"]		= self.MeleeActivity:GetClientTable(),
			["ModePicture"]			= self.ModePicture,
			["AmmoPicture"]			= self.AmmoPicture,
			["ScopePicture"]		= self.ScopePicture,
			["SightsTransform"]		= self.SightsTransform:GetClientTable(),
			["HolsterTransform"]	= self.HolsterTransform:GetClientTable(),
			["RunTransform"]		= self.RunTransform:GetClientTable(),
			["RunHolsteredTransform"]	= self.RunHolsteredTransform:GetClientTable(),
			["WallTransform"]		= self.WallTransform:GetClientTable(),
			["WallHolsteredTransform"]	= self.WallHolsteredTransform:GetClientTable(),
			["MeleeTransform"]		= self.MeleeTransform:GetClientTable(),
			["ScopeTransform"]		= self.ScopeTransform:GetClientTable()
		}
	end

end

end)